$(function () {
    let form = layui.form;
    form.verify({
        pass: [
            /^[\S]{6,12}$/
            , '密码必须6到12位，且不能出现空格'
        ]
        , samePwd: function (value) {
            if (value === $('[name=oldPwd]').val) {
                return '新旧密码不能一致！';
            }
        }
        , rePwd: function (value) {
            if (value !== $('[name=newPwd]').val()) {
                return '两次密码不一致！'
            }
        }
    });

    form.on('submit(upPwd)', function (data) {
        $.ajax({
            type: "post",
            url: "/my/updatepwd",
            data: data.field,
            success: function (response) {
                if (response.status != 0) {
                    return layer.msg('修改密码失败');
                }
                layer.msg(response.message, { icon: 6 });
            },

        });
        return false;
    })
})